package com.lupan.effectiveJava.chapter2_initAndDestroyObject;

import org.apache.commons.lang3.time.DateUtils;

import java.util.Date;

/**
 * 说明：
 *
 * @author lupan
 * @version 2016/5/27 12:27
 */
public class Main {
    public static void main(String[] args){
        /**
         * 静态工厂和构建器避免使用构造器
         */
        Student student1 = Student.newInstance();
        Student student2 = new Student.Builder("小明","0001").height(175.0).
                weight(60.0).hobby("篮球").remark("学生").build();

        /**
         * 装箱类型生成新对象效率低
         */
        Date startTime = new Date();
        Long sum = 0L;
        for(long i=0;i<Integer.MAX_VALUE;i++){
            sum +=i;
        }
        Date endTime = new Date();

        System.out.println(sum);
        System.out.println("耗时："+(endTime.getTime()-startTime.getTime())/1000+"s");
    }
}
